package com.loong.web.suppert.intercept.request;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.method.HandlerMethod;

/**
 * 请求处理器
 *
 * @author 张成轩
 */
public class RequestController {

	/** 请求参数添加器 */
	private RequestParamSetter requestParamSetter;

	/**
	 * @param request 请求
	 * @param handler 处理方法
	 */
	public void control(HttpServletRequest request, HandlerMethod handler) {

		if (requestParamSetter == null)
			return;
		ResponseBody body = handler.getMethodAnnotation(ResponseBody.class);
		if (body == null)
			requestParamSetter.setParams(request);
	}

	/**
	 * @param requestParamSetter 请求参数添加器
	 */
	public void setRequestParamSetter(RequestParamSetter requestParamSetter) {

		this.requestParamSetter = requestParamSetter;
	}
}
